var express = require('express');
var path = require('path');
var cookieParser = require('cookie-parser');
var logger = require('morgan');
require('./database/connect')  //引入连接数据库自定义js模块
var cors = require('cors')

var indexRouter = require('./routes/index');
var usersRouter = require('./routes/users');
var travelRouter = require('./routes/travel');

var app = express();

app.use(cors())  //允许客户端跨域访问
app.use(logger('dev'));
app.use(express.json());
app.use(express.urlencoded({ extended: false }));
app.use(cookieParser());
app.use(express.static(path.join(__dirname, 'public')));

// 项目路由，引导用户访问不同业务接口
app.use('/', indexRouter);
app.use('/users', usersRouter);
app.use('/travel', travelRouter);  //新增路由模块

module.exports = app;
